#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QThread>

#include "filemanager.h"
#include "tcpmanager.h"
#include "mytest.h"


int main(int argc, char *argv[])
{
    qSetMessagePattern("[%{time yyyyMMdd h:mm:ss.zzz}] "
                       "%{if-debug}[DEBUG]%{endif}"
                       "%{if-info}[INFO]%{endif}"
                       "%{if-warning}[WARN]%{endif}"
                       "%{if-critical}[CRIT]%{endif}"
                       "%{if-fatal}[FATAL]%{endif}"
                       "[%{threadid}] [%{function}] "
                       "%{file}:%{line} - %{message}");
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);

    TcpManager *tcpManager = TcpManager::instance();
    tcpManager->async();
    tcpManager->listen();

    tcpManager->connectToHost("Mytest", "127.0.0.1", 43800);

    MyTest test;

    return app.exec();
}



